Sometimes you want to try out some code and you don’t want the hassle of having to start a new project in your IDE or might not have a machine to hand to run the code. So what are your options?
If you do have access to a computer with an IntelliJ IDE then you can try either:
- Create a Scratch file.
- Use a the Kotlin REPL Run-Eval-Print-Loop
If you don’t want to run in an IDE and have the Kotlin compiler installed then you can try the command line REPL.
No IDE, compiler or computer? No problem!
These are all great solutions, but what if you don’t have access to an IDE, the command line tools installed or on machine that can run these?
I recently found myself in this position as I was reading a Kotlin book on a tablet and wanted to try out one of the coding excercises in the book. I was being lazy so didn’t want to dig out the laptop to just try out some code, so what to do?
Kotlin Playground to the rescue! Using this site you can run Kotlin code within a browser, no need for an IDE, compiler tools or computer! Granted this does limit what you can do as you won’t be able to import 3rd party libraries, but if you are just wanting to test some plain Kotlin then this works really well.
As an added bonus you can share your playground with other people similar to JSFiddle and other online programming tools.